package spring.cloud.canary.demo.controller;

import jk.framework.canary.core.CanaryMgt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jk.framework.spring.cloud.canary.loadbalancer.configure.CurrentApiVersionProperties;

@RestController
@RequestMapping("version")
public class VersionController {


    @Autowired
    private CurrentApiVersionProperties versionProperties;

    @GetMapping("current")
    public String current(){
        return versionProperties.getCurrentVersion();
    }

    @GetMapping("top")
    public String top(){
      return  CanaryMgt.getController().targetVersion().getVersion();
    }

}
